﻿using AntdUI;

namespace WorkTool2.Classes.Data
{
    public class HistoryData : NotifyProperty
    {
        public HistoryData()
        {
        }

        public HistoryData(string source, string filePath, string? remark = null, bool exists = true)
        {
            _source = source;
            _filePath = filePath;
            _remark = remark;
            Exists = exists;
            CreateTime = DateTime.Now;
        }

        public int Id { get; set; }

        private string _source;

        /// <summary>
        /// 来源
        /// </summary>
        public string Source
        {
            get => _source;
            set { _source = value; OnPropertyChanged(); }
        }

        private string _filePath;

        /// <summary>
        /// 文件地址
        /// </summary>
        public string FilePath
        {
            get => _filePath;
            set { _filePath = value; OnPropertyChanged(); }
        }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string FileName => Path.GetFileName(_filePath);

        private string _remark;

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark
        {
            get => _remark;
            set { _remark = value; OnPropertyChanged(); }
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        public bool Exists { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        public CellLink[] Action => [
            new CellButton("save", "另存为", TTypeMini.Info),
            new CellButton("open", "打开", TTypeMini.Success)
            ];
    }
}